﻿using System.Collections.Generic;
using Detective.Components.Base;
using Detective.World;

namespace Detective.Game
{
    public class DetectiveGame:BaseComponent
    {
        private List<IGameComponent>
            _components = new List<IGameComponent>();

        public volatile bool IsRun;

        public DetectiveGame()
        {
            IsRun = true;
        }

        public void AppendComponent(IGameComponent component)
        {
            _components.Add(component);
        }

        public override int GetDelayMilliSeconds()
        {
            return 100;
        }

        protected override void OnDelay(GameTime gameTime)
        {
            for (int i = 0; i < _components.Count; i++)
            {
                if (gameTime.GetDifference(_components[i].GetLastDelay()) >= _components[i].GetDelayMilliSeconds())
                {
                    _components[i].Delay(gameTime);
                }
            }
        }
    }
}
